/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			pglayer.h
  \date			Aug 2012
  \author		TNick

  \brief		Contains the definition for PgLayer class


*//*


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Please read COPYING and README files in root folder
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __PGLAYER_INC__
#define __PGLAYER_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<cpg/cpg.h>
#include	<memtrack.h>
#include	<cpg/logic/layer/lydata.h>
#include	<cpg/logic/pgittree.h>
#include	<QColor>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

namespace	cpg		{

class	PgSpace;
class	PgItem;
class	CpgDoc;

/**
*	@brief	Common ground for all kinds of layers
*
*	For an overview of the layers see \ref layers "dedicated page".
*/
class CPGSHARED_EXPORT PgLayer	: public MemTrack			{
	BBM_TRACK( PgLayer );

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

	friend class	PgItem;


	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

protected:


	/**
	*	@brief	characteristics of the layer
	*/
	LyData				d_;


	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:


	/**
	*	@brief	constructor;
	*/
	PgLayer				( void ) : MemTrack()
	{ d_.init(); }


	/**
	*	@brief	destructor;
	*/
	~PgLayer			( void )
	{ /* stub */ }


	/**
	*	@brief	tell if this layer is global or associated with a space
	*/
	virtual bool		isGlobal			( void ) const = 0;


	/**
	*	@brief	the user can see the layer on screen
	*/
	inline bool			isOpened			( void ) const
	{ return d_.isOn(); }


	/**
	*	@brief	the objects in this layer are printed
	*/
	inline bool			isPrintable			( void ) const
	{ return d_.isPrint(); }


	/**
	*	@brief	change the visibility
	*/
	inline void			setOpened			( bool b_on )
	{ d_.changeOn( b_on ); }


	/**
	*	@brief	change the print-ability
	*/
	inline void			setPrintable		( bool b_on )
	{ d_.changePrint( b_on ); }


	/**
	*	@brief	copy associated data
	*/
	inline void			getData				( LyData & d )
	{
		d = d_;
	}


	/**
	*	@brief	get associated document
	*/
	virtual CpgDoc *		document			( void ) const = 0;


	/**
	*	@brief	get the name of the layer
	*/
	inline QString		name				( void ) const
	{ return d_.s_name_; }


	/**
	*	@brief	change the name of the layer to specified name
	*/
	inline bool			setName			( const QString & s_new )
	{ d_.s_name_ = s_new; return true; }


	/**
	*	@brief	the color used to represent this layer's elements
	*/
	QColor				qtColor			( PgCtx & ctx )
	{ return PgColor::qtColor( ctx, d_.color_ ); }


	/**
	*	@brief	the color as an index
	*/
	inline PgColor::Id	color			( void )
	{ return d_.color_; }


	/**
	*	@brief	the line pattern as an index
	*/
	inline PgLnPattern::Id	lnPattern		( void )
	{ return d_.ln_patt_; }


	/**
	*	@brief	the weight of lines
	*/
	inline qreal			lineWeight		( void )
	{ return d_.ln_weight_; }


	/**
	*	@brief	the scale for line pattern
	*/
	inline qreal			linePattScl		( void )
	{ return d_.ln_scale_; }


	/**
	*	@brief	get the PgItTree of items belonging to this layer in provided space
	*/
	virtual PgItTree *		items			( PgSpace * spc ) = 0;


protected:


	/**
	*	@brief	change associated data
	*/
	inline void				setData				( const LyData & d )
	{
		d_ = d;
	}


	/**
	*	@brief	add an item to layer's PgItTree in provided space
	*/
	virtual bool		addItem				(
			PgSpace *		spc,
			PgItem *		itm
			) = 0;


	/**
	*	@brief	remove an item from layer's PgItTree in provided space
	*/
	virtual bool		remItem				(
			PgSpace *		spc,
			PgItem *		itm
			) = 0;


	/**
	*	@brief	emmit signal informing that a layer was created
	*/
	static void			raiseLayerCreated	( PgSpace * space, PgLayer * layer );


	/**
	*	@brief	emmit signal informing that a layer was removed
	*/
	static void			raiseLayerDeleted	( PgSpace * space, PgLayer * layer );



	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class PgLayer	*/

/*  CLASS    =============================================================== */
//
//
//
//

}	//	namespace	cpg

#endif // __PGLAYER_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
